#pragma once
#ifndef xIApp_h__
#define xIApp_h__

#include "./xLib.h"

namespace Sky
{
	class xIApp : public Object
	{
		DECL_RTTI1(xIApp,Object);
	public:
		//------------------------------------------------------------------------------------
		//Create the 3d environment
		//------------------------------------------------------------------------------------
		virtual TResult Create3DEnv()=0;
		//------------------------------------------------------------------------------------
		//Create the main window,then use Create3DDevice()
		//------------------------------------------------------------------------------------

		virtual TResult Create3DWindow(const TChar* strWindowTitle = vNull,
			TUint dwWinStyle=WS_POPUP,
			TInt nDefaultX=0,TInt nDefaultY=0,TInt nDefaultWidth=1024,TInt nDefaultHeight=768,
			WNDPROC wndProc=vNull/*if vNull,use default*/) = 0;
		//------------------------------------------------------------------------------------
		//Set the window that will be rendered,then use Create3DDevice()
		//------------------------------------------------------------------------------------
		virtual TResult Set3DWindow(HWND hWnd,TBool handlemsg=vFalse) = 0;
		//------------------------------------------------------------------------------------
		//The message loop
		//------------------------------------------------------------------------------------
		virtual TResult MainLoop(TBool bWinProc = vFalse,TBool need3D = vFalse) = 0;
		//------------------------------------------------------------------------------------
		//Get the exit code
		//------------------------------------------------------------------------------------
		virtual TInt		GetExitCode() = 0;
		//------------------------------------------------------------------------------------
		//Set the exit code
		//------------------------------------------------------------------------------------
		virtual TVoid	SetExitCode(ExitCode code) = 0;
		//------------------------------------------------------------------------------------
		//Set the TResult code
		//------------------------------------------------------------------------------------
		virtual TVoid SetResult(TInt hr) = 0;
		//------------------------------------------------------------------------------------
		//Set the TResult code
		//------------------------------------------------------------------------------------
		virtual TResult GetResult() = 0;
		//------------------------------------------------------------------------------------
		//Set the TResult code
		//------------------------------------------------------------------------------------
		virtual TVoid	ShowWindow(TBool bShow = vTrue) = 0;
	public:
		//------------------------------------------------------------------------------------
		//Called to rendered object
		//in XApp::OnRenderSceneLoop(),Objects added called OnRenderSceneLoop() function
		//------------------------------------------------------------------------------------
		virtual TResult	RenderSceneLoop() = 0;
		//------------------------------------------------------------------------------------
		//Called to handle message
		//in XApp::OnHandlerMessageLoop(),Objects added called OnHandlerMessageLoop() function
		//------------------------------------------------------------------------------------
		virtual TResult	HandleMessageLoop() = 0;
		//------------------------------------------------------------------------------------
		//Called to handle message
		//in XApp::HandleWinPorc(),Objects added called HandleWinPorc() function
		//------------------------------------------------------------------------------------
		virtual TResult	HandleWinPorc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) = 0;

	public:

		//------------------------------------------------------------------------------------
		//Force the engine to exit,and release pd3ddevice
		//------------------------------------------------------------------------------------
		virtual TVoid	Shutdown(ExitCode code = ExitCode_Exit) = 0;
		//------------------------------------------------------------------------------------
		//use positive number to increase the times paused,
		//and negative number to decrease the times paused
		//------------------------------------------------------------------------------------
		virtual TVoid	AddPauseCount(TInt PauseTimeCount=0,TInt PauseRenderCount=0) = 0;
		//
		virtual ExitCode Exit() = 0;
	};
}

#endif // xIApp_h__